<?php

//created 6/14/12
//print_r($region_data);


echo "<br>My Titles</br>";

if (isset($title_data)) {
    // has titles
    foreach ($title_data as $row) {
        
        echo "<br>Title id: " . $row->getId() . ", to region " . $row->getRegionLink()->getId();
        $region_id = $row->getRegionLink()->getId();
        //$region_id_obj = (object) $region_id;
        
        //$key = array_search($region_id_obj, $region_data);
        //echo "key: $key";
        
        foreach ($region_data as $row2) {
            if ($row2->getId() == $region_id) {
                //echo "Got a match.";
                echo ", region name: " . $row2->getRegionName() . ", available soldiers " . $row2->getAvailSoldiers() . "</br>";
                if(isset($claim_data)) {
                    //echo "Claim.";
                    foreach ($claim_data as $row3) {
                        // there is a claim against one of our titles.
                        if ($row3->getTitleLink()->getId() == $row->getId()) {
                            echo "There is a claim against this title!";
                        }
                    }
                }
            }
        }
        
        
    } // end foreach title_data
    
} else {
    // does not have titles
    echo "<brYou have no titles!</br>";
}